//
// Created by luosong on 15/8/27.
// Copyright (c) 2015 CHANJET. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CSPNetworking.h"
#import "CSPRequestConfig.h"

@class CSPNetworkingRequest;

@protocol CSPRequestDelegate <NSObject>

- (void)requestFinished:(CSPNetworkingRequest *)request;
- (void)requestFailed:(CSPNetworkingRequest *)request;

@optional
- (void)clearRequest;

@end

@protocol CSPRequestAccessory <NSObject>
@optional

- (void)requestWillStart:(id)request;
- (void)requestWillStop:(id)request;
- (void)requestDidStop:(id)request;

@end

@interface CSPNetworkingRequest : CSPRequestConfig

/// Tag
@property (nonatomic) NSInteger tag;

@property (nonatomic, strong) NSDictionary *parameters;
@property (nonatomic, strong) NSURL *uploadingFileURL;
@property (nonatomic, strong) NSURL *downloadingFileURL;
@property (nonatomic, assign) BOOL shouldWriteDirectly;

@property (nonatomic, copy) CSPNetworkingUploadProgressBlock uploadProgress;
@property (nonatomic, copy) CSPNetworkingDownloadProgressBlock downloadProgress;

@property (readonly, nonatomic, strong) NSURLSessionTask *task;
@property (readonly, nonatomic, assign, getter = isCancelled) BOOL cancelled;

- (void)assignProperties:(CSPRequestConfig *)configuration;
- (void)cancel;
- (void)pause;

@end
